package com.example.recycler.scroller;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.Scroller;

/**
 * Created by Administrator on 2017/3/6.
 */

public class S_ViewGroup extends LinearLayout{
   private  boolean s1=true;
    Scroller mScroller=null;

    public S_ViewGroup(Context context) {
        super(context);
    }

    public S_ViewGroup(Context context, AttributeSet attrs) {
        super(context, attrs);
        mScroller=new Scroller(context);
    }
    @Override

    public void computeScroll() {
        if (mScroller.computeScrollOffset()) {
            scrollTo(mScroller.getCurrX(), 0);
            postInvalidate();
        }
    }
    public void beginScroll(){
        if (!s1) {
            mScroller.startScroll(0, 0, 0, 0, 3000);
            s1 = true;
        } else {
            mScroller.startScroll(0, 0, 600, 0, 3000);
            s1 = false;
        }
        invalidate();
    }
}
